from django.shortcuts import render
from django.http import HttpResponse
from . import models


def index(request):
    # return HttpResponse('a')
    # a = models.Employee.objects.get(pk=2)
    a = models.Employee.objects.all()
    return render(request, 'blog/index.html', {'abc': a})


def test_id(request, my_id):
    return HttpResponse(my_id)


def my_post(request):
    name = request.POST.get('title1', 'abc')  # 设置默认值abc防止异常
    name01 = request.POST.get('title2', 'ww')
    text = models.Employee.objects.create(name=name, name01=name01)
    print(text)
    return HttpResponse('add ok')
